
if [ $# -ne 2 ]
then
  echo Usage: run-test prog testname
  exit 0
fi

if [ -e in/$2 ]
then
  echo Running test $2:
  cat desc/$2
  echo
  ./$1 < in/$2 > stdout.tmp 2> stderr.tmp
  echo Output written to stdout.tmp and stderr.tmp
  (diff --ignore-all-space stdout.tmp out/$2 > /dev/null && echo Stdout OK) || (
    echo ==== Stdout differs! Should be: ===
    cat out/$2
    echo
    echo ============== But was: ===========
    cat stdout.tmp
    echo ================ EOF ==============
    )
  (diff --ignore-all-space stderr.tmp err/$2 > /dev/null && echo Stderr OK)|| (
    echo ==== Stderr differs! Should be: ===
    cat err/$2
    echo
    echo ============== But was: ===========
    cat stderr.tmp
    echo ================ EOF ==============
    )
else
  echo No such test
fi
